﻿#include "FITKDataCaseManager.h"
#include "FITKDataCase.h"

//命名空间
namespace AbaqusData
{

    void FITKDataCaseManager::removeDataObj(Core::FITKAbstractDataObject* obj)
    {
        //只有1个禁止移除
        if (this->getDataCount() < 2) return;
        Core::FITKAbstractDataManager< FITKDataCase >::removeDataObj(obj);
    }

    void FITKDataCaseManager::removeDataByIndex(int index)
    {
        //只有1个禁止移除
        if (this->getDataCount() < 2) return;
        Core::FITKAbstractDataManager< FITKDataCase >::removeDataByIndex(index);
    }

    void FITKDataCaseManager::removeDataByID(int id)
    {
        //只有1个禁止移除
        if (this->getDataCount() < 2) return;
        Core::FITKAbstractDataManager< FITKDataCase >::removeDataByID(id);
    }

    void FITKDataCaseManager::removeDataByName(const QString &name, bool s)
    {
        //只有1个禁止移除
        if (this->getDataCount() < 2) return;
        Core::FITKAbstractDataManager< FITKDataCase >::removeDataByName(name,s);
    }

    void FITKDataCaseManager::clearAllCase()
    {
        Core::FITKAbstractDataManager< FITKDataCase >::clear();
    }


    void FITKDataCaseManager::checkCaseNum()
    {
        const int n = this->getDataCount();
        if (n > 0) return;
        FITKDataCase* acase = new FITKDataCase;
        acase->setDataObjectName("Model-1");
        this->appendDataObj(acase);
    }

    void FITKDataCaseManager::appendDataObj(Core::FITKAbstractDataObject* item)
    {
        QMutexLocker locker(&_mutex);
        if (_dataList.contains(item))
            delete item;
        else
        {
            _helper->appendData(item);
            _helper->sortObject(Core::DataName);
        }
        
    }

}